﻿using System;
using System.Text;
using System.Threading.Tasks;
using Wx.Sdk.MiniProgram.Entity;
using Wx.Sdk.Utils;

namespace Wx.Sdk.MiniProgram.Src
{
	public class MiniProgramQrCode: IMiniProgramQrCode
	{
        WxMiniProgram wxApp;
        public MiniProgramQrCode(WxMiniProgram wxApp)
        {
            this.wxApp = wxApp;
        }
        async Task<byte[]> IMiniProgramQrCode.GetWxaCodeUnlimit(PageInfo pageInfo)
        {
            var token = await wxApp.appBase.GetAccessToken();
            var url = $"https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={token}";
            var body = JsonHelper.ToJson(pageInfo);
            var bytes= await wxApp.appBase.PostByte(body,url);
            return bytes;
        }
    }
}

